/* 倒药水游戏样式（改进版） */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #87CEEB 0%, #98FB98 50%, #90EE90 100%);
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

/* 瓜田背景装饰 */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(circle at 20% 80%, rgba(255, 165, 0, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(255, 192, 203, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(144, 238, 144, 0.1) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
}

/* 瓜藤装饰 */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100' viewBox='0 0 100 100'%3E%3Cpath d='M20 20 Q 30 10, 40 20 T 60 20' stroke='%2332CD32' stroke-width='2' fill='none' opacity='0.3'/%3E%3Cpath d='M10 60 Q 20 50, 30 60 T 50 60' stroke='%2332CD32' stroke-width='2' fill='none' opacity='0.3'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: -1;
}

.game-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    position: relative;
    z-index: 1;
}

/* 游戏头部 */
.game-header {
    text-align: center;
    margin-bottom: 20px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 15px;
    padding: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.score-info {
    display: flex;
    justify-content: space-around;
    margin-bottom: 10px;
    font-size: 14px;
    color: #2c3e50;
}

.game-title {
    color: #27ae60;
    font-size: 28px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

/* 控制按钮 */
.control-buttons {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
}

.control-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 10px 15px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
    transition: all 0.3s ease;
    position: relative;
    min-width: 70px;
}

.hint-btn {
    background: linear-gradient(145deg, #3498db, #2980b9);
    color: white;
}

.help-btn {
    background: linear-gradient(145deg, #e74c3c, #c0392b);
    color: white;
}

.restart-btn {
    background: linear-gradient(145deg, #3498db, #2980b9);
    color: white;
}

.undo-btn {
    background: linear-gradient(145deg, #9b59b6, #8e44ad);
    color: white;
}

.add-tube-btn {
    background: linear-gradient(145deg, #f39c12, #e67e22);
    color: white;
}

.control-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.control-btn:active {
    transform: translateY(0);
}

/* 按钮图标 */
.btn-icon {
    width: 24px;
    height: 24px;
    position: relative;
}

.lightbulb-icon::before {
    content: '💡';
    font-size: 20px;
}

.help-icon::before {
    content: '🆘';
    font-size: 20px;
}

.restart-icon::before {
    content: '🔄';
    font-size: 20px;
}

.undo-icon::before {
    content: '↶';
    font-size: 20px;
    font-weight: bold;
}

.tube-icon::before {
    content: '🧪';
    font-size: 20px;
}

/* 计数徽章 */
.count-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #e74c3c;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

/* 游戏区域 */
.game-area {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 30px 20px;
    margin-bottom: 20px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    position: relative;
}

.tubes-container {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 15px;
    flex-wrap: wrap;
    min-height: 200px;
    position: relative;
}

/* 试管样式 */
.tube {
    width: 50px;
    height: 150px;
    border: 3px solid #34495e;
    border-radius: 0 0 25px 25px;
    background: rgba(255, 255, 255, 0.9);
    position: relative;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column-reverse;
    overflow: hidden;
    transform-origin: bottom center;
}

.tube:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

/* 选中状态样式优化 */
.tube.selected {
    border-color: #f39c12;
    border-width: 4px;
    box-shadow: 
        0 0 25px rgba(243, 156, 18, 0.6),
        0 8px 20px rgba(243, 156, 18, 0.3);
    transform: translateY(-20px) scale(1.1);
    z-index: 100;
}

/* 选中动画 */
@keyframes selectTube {
    0% {
        transform: translateY(0) scale(1);
        border-color: #34495e;
        box-shadow: none;
    }
    50% {
        transform: translateY(-10px) scale(1.05);
        border-color: #f39c12;
        box-shadow: 0 0 15px rgba(243, 156, 18, 0.4);
    }
    100% {
        transform: translateY(-20px) scale(1.1);
        border-color: #f39c12;
        box-shadow: 
            0 0 25px rgba(243, 156, 18, 0.6),
            0 8px 20px rgba(243, 156, 18, 0.3);
    }
}

/* 取消选中动画 */
@keyframes deselectTube {
    0% {
        transform: translateY(-20px) scale(1.1);
        border-color: #f39c12;
        box-shadow: 
            0 0 25px rgba(243, 156, 18, 0.6),
            0 8px 20px rgba(243, 156, 18, 0.3);
    }
    100% {
        transform: translateY(0) scale(1);
        border-color: #34495e;
        box-shadow: none;
    }
}

.tube.selecting {
    animation: selectTube 0.3s ease-out forwards;
}

.tube.deselecting {
    animation: deselectTube 0.3s ease-out forwards;
}

/* 移动动画 */
.tube.moving {
    z-index: 200;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 目标试管高亮 */
.tube.target-highlight {
    border-color: #2ecc71;
    box-shadow: 0 0 15px rgba(46, 204, 113, 0.5);
    animation: targetPulse 1s infinite;
}

@keyframes targetPulse {
    0%, 100% { 
        box-shadow: 0 0 15px rgba(46, 204, 113, 0.5);
        border-color: #2ecc71;
    }
    50% { 
        box-shadow: 0 0 25px rgba(46, 204, 113, 0.8);
        border-color: #27ae60;
    }
}

.tube.hint-highlight {
    animation: hintPulse 1s infinite;
}

@keyframes hintPulse {
    0%, 100% { box-shadow: 0 0 20px rgba(46, 204, 113, 0.8); }
    50% { box-shadow: 0 0 30px rgba(46, 204, 113, 1); }
}

/* 液体组样式（相邻同色合并） */
.liquid-group {
    width: 100%;
    transition: all 0.5s ease;
    position: relative;
    border-radius: 0;
}

/* 只有顶部组才显示分割线 */
.liquid-group.has-separator::after {
    content: '';
    position: absolute;
    top: 0;
    left: 5%;
    right: 5%;
    height: 2px;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 1px;
}

/* 液体颜色 */
.color-red { 
    background: linear-gradient(180deg, #e74c3c, #c0392b);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.color-yellow { 
    background: linear-gradient(180deg, #f1c40f, #f39c12);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.color-blue { 
    background: linear-gradient(180deg, #3498db, #2980b9);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.color-green { 
    background: linear-gradient(180deg, #2ecc71, #27ae60);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* 瓶塞样式 */
.bottle-cap {
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 35px;
    height: 15px;
    background: linear-gradient(145deg, #8b4513, #654321);
    border-radius: 8px 8px 4px 4px;
    border: 2px solid #5d4037;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    z-index: 10;
}

.bottle-cap::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 3px;
    background: #3e2723;
    border-radius: 2px;
}

/* 瓶塞出现动画 */
@keyframes bottleCapAppear {
    0% {
        transform: translateX(-50%) translateY(-20px) scale(0);
        opacity: 0;
    }
    50% {
        transform: translateX(-50%) translateY(-5px) scale(1.2);
        opacity: 0.8;
    }
    100% {
        transform: translateX(-50%) translateY(0) scale(1);
        opacity: 1;
    }
}

/* 底部控制区域 */
.bottom-controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

/* 对话框样式 */
.win-dialog, .hint-dialog {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: opacity 0.3s ease;
}

.dialog-content {
    background: white;
    padding: 30px;
    border-radius: 20px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.dialog-content h2, .dialog-content h3 {
    color: #27ae60;
    margin-bottom: 20px;
}

.win-stats {
    margin: 20px 0;
    color: #2c3e50;
}

.win-stats p {
    margin: 10px 0;
    font-size: 16px;
}

.dialog-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 20px;
}

.dialog-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.3s ease;
}

.dialog-btn.primary {
    background: linear-gradient(145deg, #27ae60, #2ecc71);
    color: white;
}

.dialog-btn.secondary {
    background: linear-gradient(145deg, #95a5a6, #7f8c8d);
    color: white;
}

.dialog-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* 隐藏类 */
.hidden {
    display: none !important;
}

/* 动画效果 */
.complete-animation {
    animation: completeGlow 1s ease-in-out;
}

@keyframes completeGlow {
    0%, 100% { 
        box-shadow: 0 0 10px rgba(46, 204, 113, 0.5);
    }
    50% { 
        box-shadow: 0 0 30px rgba(46, 204, 113, 1);
        transform: scale(1.1);
    }
}

/* 庆祝星星效果 */
.celebration-star {
    position: fixed;
    width: 10px;
    height: 10px;
    background: #f1c40f;
    clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
    z-index: 1500;
    animation: starBurst 1s ease-out forwards;
}

@keyframes starBurst {
    0% {
        transform: scale(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: scale(1) rotate(360deg);
        opacity: 0;
    }
}

/* 液体流动动画 */
.liquid-stream {
    background: linear-gradient(to bottom, 
        rgba(52, 152, 219, 0.8) 0%,
        rgba(52, 152, 219, 0.6) 50%,
        rgba(52, 152, 219, 0.4) 100%);
    border-radius: 2px;
    animation: liquidFlow 0.6s ease-in-out;
}

@keyframes liquidFlow {
    0% { height: 0; opacity: 0; }
    50% { opacity: 1; }
    100% { opacity: 0.8; }
}

.liquid-droplet {
    border-radius: 50%;
    animation: dropletFall 0.4s ease-in;
}

@keyframes dropletFall {
    0% { transform: scale(1); opacity: 1; }
    100% { transform: scale(0.5); opacity: 0; }
}

/* 倒液体动画容器 */
.pour-animation-container {
    pointer-events: none;
    z-index: 1000;
}

/* 消息提示动画 */
@keyframes fadeInOut {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
    20% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    80% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
}

/* 响应式设计 */
@media (max-width: 768px) {
    .game-container {
        padding: 10px;
    }
    
    .tubes-container {
        gap: 10px;
    }
    
    .tube {
        width: 40px;
        height: 120px;
    }
    
    .control-buttons {
        gap: 10px;
    }
    
    .bottom-controls {
        gap: 10px;
    }
    
    .control-btn {
        min-width: 60px;
        padding: 8px 12px;
        font-size: 11px;
    }
}